#include <bits/stdc++.h>
#define sayyes cout<<"YES"<<endl;
#define sayno cout<<"NO"<<endl;
using namespace std;
int main(){
    int T,l,l2;
    int a[300][505];
    bool f,f2;
    cin>>T;
    while(T--){
        f=false;
        string s=" ",s2=" ",steam;
        cin>>steam;
        s+=steam;
        cin>>steam;
        s2+=steam;
        l=s.size()-1;
        l2=s2.size()-1;
        for(int i=0;i<300;i++)a[i][0]=0;
        for(int i=1;i<=l;i++){
            a[s[i]][++a[s[i]][0]]=i;
        }
        for(int i=1;i<=a[s2[1]][0];i++){
            int index_forcodeforce_areyoukidingme_andwhythegetsfoolme_holyshit=a[s2[1]][i];
            bool righting=true;
            f2=true;
            for(int j=2;j<=l2;j++){
                if(righting){
                    if(index_forcodeforce_areyoukidingme_andwhythegetsfoolme_holyshit+1<=l&&s[index_forcodeforce_areyoukidingme_andwhythegetsfoolme_holyshit+1]==s2[j]){
                        index_forcodeforce_areyoukidingme_andwhythegetsfoolme_holyshit++;
                    }else{
                        righting=false;
                        j--;
                    }
                }else{
                    if(index_forcodeforce_areyoukidingme_andwhythegetsfoolme_holyshit>1&&s[index_forcodeforce_areyoukidingme_andwhythegetsfoolme_holyshit-1]==s2[j]){
                        index_forcodeforce_areyoukidingme_andwhythegetsfoolme_holyshit--;
                    }else{
                        f2=false;
                        break;
                    }
                }
            }
            if(f2){
                sayyes
                f=true;
                break;
            }
        }
        if(!f)sayno
    }
    return 0;
}